package com.heima.article.controller;

import com.heima.article.service.ApArticleService;
import com.heima.model.article.dto.ArticleDto;
import com.heima.model.article.dto.ArticleHomeDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/article")
public class ArticleController {

    @Autowired
    private ApArticleService apArticleService;

    @PostMapping(path = "/save")
    public ResponseResult save(@RequestBody ArticleDto dto) {
        return apArticleService.save(dto);
    }

    //加载首页
    @PostMapping("load")
    public ResponseResult load(@RequestBody ArticleHomeDto dto ){
        return  apArticleService.queryMoreAndNew(dto);

    }

    //**加载更多**
    @PostMapping("loadmore")
    public ResponseResult loadmore(@RequestBody ArticleHomeDto dto){
        return  apArticleService.queryMoreAndNew(dto);
    }


    //| **加载最新** |
    @PostMapping("loadnew")
    public ResponseResult loadnew(@RequestBody ArticleHomeDto dto){
        return  apArticleService.queryMoreAndNew(dto);
    }


}
